package controllers.similarity;

import models.PropertyModel;


public class PropertyComparison implements Comparable<PropertyComparison>
{
    PropertyModel p1;
    PropertyModel p2;
    float         propertySimilarity = 0;
    float         valueSimilarity    = 0;


    public PropertyComparison(PropertyModel p1, PropertyModel p2)
    {
        this.p1 = p1;
        this.p2 = p2;
    }


    public float getPropertySimilarity()
    {
        return propertySimilarity;
    }


    public void setPropertySimilarity(float similarity)
    {
        this.propertySimilarity = similarity;
    }


    public float getValueSimilarity()
    {
        return valueSimilarity;
    }


    public void setValueSimilarity(float similarity)
    {
        this.valueSimilarity = similarity;
    }


    public PropertyModel getP1()
    {
        return p1;
    }


    public PropertyModel getP2()
    {
        return p2;
    }


    @Override
    public String toString()
    {
        return String.format("%-60s", p1.getURI()) + " - " + String.format("%-60s", p2.getURI()) + " -> " + propertySimilarity + " | " + valueSimilarity;
    }


    @Override
    public int compareTo(PropertyComparison pc)
    {
        if(this.propertySimilarity <= pc.propertySimilarity) {
            return -1;
        } else {
            return 1;
        }
    }


    public float getWeight()
    {
        return (float) Math.sqrt(propertySimilarity*valueSimilarity);
    }
}
